import { get, post, IList } from "./index";

// 数据管理-数据集列表
export interface DataSetQuery {
    name: string;
    page: number;
    pageSize: number;
}

export interface DatasetItem {
    createTime: string;
    id: number;
    name: string;
    size: string;
    type: string[];
    isShare: number; // 1：共享；2：个人
}

export const getDatasetList = async (data: DataSetQuery): Promise<IList<DatasetItem>> => {
    const res = await post("/dataset/private/list", data);
    return {
        list: res.data.dataSetPrivateDtoList || [],
        total: res.data.total || 0,
    };
};

// 创建数据集
export const createDataset = async (data: { name: string; type: string[] }) =>
    await post("/dataset/create", data);

interface UpdateParam {
    id: number;
    name: string;
    type: string[];
}
// 更新数据集
export const updateDataset = async (data: UpdateParam) => await post("/dataset/update", data);

// 删除数据集
export const delDataset = async (data: { id: number }) => await post("/dataset/delete", data);

// 更新数据集
export const publicShareDataset = async (data: { id: number; share: number }) => {
    const result = await post("/dataset/publicShare", data);
    return result;
};
